//
//  UIButton+TYTheme.m
//  AFNetworking
//
//  Created by 尼奥 on 2020/9/10.
//

#import "UIButton+TYTheme.h"
#import "UIColor+TYTheme.h"
#import "TYTheme.h"

@implementation UIButton (TYTheme)

- (void)ty_setPrimaryButtonTheme {
    [self setBackgroundImage:[TYTheme.theme.primary_button_bg_color ty_convertToImage] forState:UIControlStateNormal];
    [self setBackgroundImage:[TYTheme.theme.primary_button_select_color ty_convertToImage] forState:UIControlStateSelected];
    [self setBackgroundImage:[[TYTheme.theme.primary_button_bg_color ty_themeColorWithAlpha:0.2] ty_convertToImage] forState:UIControlStateDisabled];
    
    self.layer.cornerRadius = TY_ThemeScreenAdaptionLength(TYTheme.theme.C1_1);
    self.layer.masksToBounds = YES;
    
    [self setTitleColor:TYTheme.theme.primary_button_font_color forState:UIControlStateNormal];
}

- (void)ty_setSecondaryButtonTheme {
    [self setBackgroundImage:[TYTheme.theme.secondary_button_bg_color ty_convertToImage] forState:UIControlStateNormal];
    [self setBackgroundImage:[TYTheme.theme.secondary_button_select_color ty_convertToImage] forState:UIControlStateSelected];
    [self setBackgroundImage:[[TYTheme.theme.secondary_button_bg_color ty_themeColorWithAlpha:0.2] ty_convertToImage] forState:UIControlStateDisabled];
    
    self.layer.cornerRadius = TY_ThemeScreenAdaptionLength(TYTheme.theme.C1_1);
    self.layer.masksToBounds = YES;

    [self setTitleColor:TYTheme.theme.secondary_button_font_color forState:UIControlStateNormal];
}

@end
